package java_DesignPattern.BehavioralPattern.ObserverPattern;

import java.util.ArrayList;
import java.util.List;

// 公众号类---具体的主题类
public class GZH implements Subject{

    private List<Observer> observers = new ArrayList<>();

    @Override
    public void registerObserver(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObservers() {

        for (Observer observer : observers) {
            observer.update();
        }
    }
}
